﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace _2014112107
{
    public partial class UserUpdate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112107;uid=2014112107;pwd=19951106";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                StringBuilder SqlStringBuilder = new StringBuilder(1024);
                SqlStringBuilder.Append("UPDATE  project ");
                SqlStringBuilder.AppendFormat("SET         项目1 = N'{0}', 支出额= N'{1}',  项目2 = N'{2}', 收入额= N'{3}', 备注= N'{4}'", this.txtProject1.Text, this.txtNum1.Text, this.txtProject2.Text, this.txtNum2.Text, this.txtMemo.Text);
                SqlStringBuilder.AppendFormat("WHERE   (日期 = N'{0}') ", this.txtDate.Text);
                string strSql = SqlStringBuilder.ToString();

                SqlCommand cmd = new SqlCommand(strSql, cn);
                int iUpd = cmd.ExecuteNonQuery();
                if (iUpd < 1)
                {
                    this.lblInfo.Text = "更新失败！";
                }
                else
                {
                    this.lblInfo.Text = "更新" + iUpd.ToString() + "条记录！";
                }
            }
            catch (Exception ex)
            {
                this.lblInfo.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

    }
}